id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Lambda IntroNoArgLambda4

prev  |  next  |  chance

// Higher-order function as a return type
fun funcGen1(i: Int): () -> Int {
  return { i }
}

fun funcNoArg4a(i: Int, j: Int): Int = i * funcGen1(j).invoke()

fun funcNoArg4b(i: Int, j: Int): Int = i * funcGen1(j)()

Function Call  Return Value
funcNoArg4a(5, 10)
funcNoArg4a(10, 15)
funcNoArg4b(6, 12)
funcNoArg4b(20, 25)

Experiment with this code on Gitpod.io or as a Kotlin Playground

⬅ Back